<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  header("location:checklogin.php");
}

$partyDetailArray = 0;
$i=0;
$partyDetailArray = array();
$selectParty = "SELECT partyDetailId,item,rate,rateWithBill,fromTable.branchName AS fromName ,toTable.branchName AS toName
                       FROM partyDetail
                       LEFT JOIN branch AS fromTable ON fromTable.branchId = partyDetail.fromId
                       LEFT JOIN branch AS toTable   ON toTable.branchId = partyDetail.toId
                       WHERE partyId = ".$_GET['partyId']."
                       ORDER BY item";
$selectPartyRes = mysql_query($selectParty);
while($partyRow = mysql_fetch_array($selectPartyRes))
{
	$partyDetailArray[$i]['partyDetailId']    = $partyRow['partyDetailId'];
	$partyDetailArray[$i]['fromName']         = $partyRow['fromName'];
	$partyDetailArray[$i]['toName']           = $partyRow['toName'];
	$partyDetailArray[$i]['item']             = $partyRow['item'];
	$partyDetailArray[$i]['rate']             = $partyRow['rate'];
	$partyDetailArray[$i]['rateWithBill']     = $partyRow['rateWithBill'];
	$i++;
}


$i=0;
$partyArray = array();
$selectParty = "SELECT partyId,name,firmName,address,telNo,mobileNo,remarks
                  FROM party
              WHERE partyId = ".$_GET['partyId'];
$selectPartyRes = mysql_query($selectParty);
while($partyRow = mysql_fetch_array($selectPartyRes))
{
  $partyArray[$i]['partyId']          = $partyRow['partyId'];
  $partyArray[$i]['name']             = $partyRow['name'];
  $partyArray[$i]['firmName']         = $partyRow['firmName'];
  $partyArray[$i]['address']          = $partyRow['address'];
  $partyArray[$i]['telNo']            = $partyRow['telNo'];
  $partyArray[$i]['mobileNo']         = $partyRow['mobileNo'];
  $partyArray[$i]['remarks']          = $partyRow['remarks'];
  $i++;
}
include("./bottom.php");
$smarty->assign("partyDetailArray",$partyDetailArray);
$smarty->assign("partyArray",$partyArray);
$smarty->display("partyDetail.tpl");
?>